package org.misty.redis.web;

import org.misty.redis.bloomfilter.BloomFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicInteger;

@RestController
@RequestMapping("/bloom")
public class BloomFilterController {
    private static final AtomicInteger num = new AtomicInteger(1);

    @Autowired
    private BloomFilter testFilter;

    @Autowired
    private BloomFilter test2Filter;

    @Autowired
    private BloomFilter test3Filter;

    @GetMapping("/test")
    public String test() {
        String id = String.valueOf(num.getAndIncrement());
        testFilter.put(id);
        return "ok";
    }

    @GetMapping("/test2")
    public String test2() {
        String id = String.valueOf(num.getAndIncrement());
        test2Filter.put(id);
        return "ok";
    }

    @GetMapping("/test3")
    public String test3() {
        String id = String.valueOf(num.getAndIncrement());
        test3Filter.put(id);
        return "ok";
    }
}
